library NOTDAMisc requires GlobalVariables

	globals
		private timer array             udg_timerstack
		private integer                 udg_ntimer                 = 0
	endglobals
	
	function debugmsg takes string s returns nothing
	   if( udg_debug == true) then
		   call DisplayTextToForce( GetPlayersAll(), "Debug: " + s )
	   endif
	endfunction

	function L2S takes location l returns string
		local real x = GetLocationX(l)
		local real y = GetLocationY(l)
		local string rval = "("+R2S(x)+","+R2S(y)+")"
		return rval
	endfunction


	function NewTimer takes nothing returns timer
		if udg_ntimer == 0 then
			return CreateTimer()
		else
			set udg_ntimer = udg_ntimer-1
			return udg_timerstack[udg_ntimer]
		endif
	endfunction

	function ReleaseTimer takes timer t returns nothing
		call PauseTimer(t)
		if udg_ntimer == 8190 then
			call BJDebugMsg("Warning: Timer limit (8191) reached")
			call DestroyTimer(t)
		else
			set udg_timerstack[udg_ntimer] = t
			set udg_ntimer = udg_ntimer + 1
		endif
	endfunction

endlibrary
